#include "shape.h"

Shape::Shape(QString name,
             double refraction,
             double diffusion,
             double specularity,
             double glossy,
             double roughness,
             Vector emission,
             Vector absorbtion,
             Vector position,
             Vector rotation):
    _name(name),
    _refraction(refraction),
    _diffusion(diffusion),
    _specularity(specularity),
    _glossy(glossy),
    _roughness(roughness),
    _emission(emission),
    _absorbtion(absorbtion),
    _position(position),
    _rotation(rotation)
{
    double probabilities[] = {_diffusion ,
                              _specularity,
                              _refraction};
    _dist = discrete_distribution<>(probabilities);
}

Shape::~Shape()
{
}

bool Shape::operator ==(const Shape &value)
{
    return (value._name == this->_name);
}

const Box &Shape::getBoundingBox() const
{
    return _bounds;
}

bool Shape::isEmiter() const
{
    return (_emission != Vector(0.0,0.0,0.0));
}

double Shape::refraction() const
{
    return _refraction;
}

double Shape::diffusion() const
{
    return _diffusion;
}

double Shape::specularity() const
{
    return _specularity;
}

const Vector &Shape::emission() const
{
    return _emission;
}

const Vector &Shape::absorbtion() const
{
    return _absorbtion;
}

const Vector &Shape::position() const
{
    return _position;
}

const Vector &Shape::rotation() const
{
    return _rotation;
}

double Shape::glossy() const
{
    return 1.0-_glossy;
}

double Shape::roughness() const
{
    return 1.0-_roughness;
}

void Shape::setGlossy(double value)
{
    _glossy = value;
}

void Shape::setRoughness(double value)
{
    _roughness = value;
}

void Shape::setRefraction(double value)
{
    _refraction = value;
}

void Shape::setDiffusion(double value)
{
    _diffusion = value;
}

void Shape::setSpecularity(double value)
{
    _specularity = value;
}

void Shape::setEmission(const Vector &value)
{
    _emission = value;
}

void Shape::setAbsorbtion(const Vector &value)
{
    _absorbtion = value;
}

void Shape::setPosition(const Vector &value)
{
    _position = value;
}

void Shape::setRotation(const Vector &value)
{
    _rotation = value;
}

QDataStream &operator<<(QDataStream &s, const Shape & shape)
{
    return s;
}

QDataStream &operator>>(QDataStream &s, Shape & shape)
{
    //    QString type;
    //    s >> type;
    //    switch (type) {
    //    case "Sphere":
    //        Shpere* sphere = new Sphere();
    //        s >> sphere;
    //        shape = sphere;
    //        break;
    //    default:
    //        break;
    //    }
    return s;
}
